import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Buck Class
 * @author Hugo Armando Rodríguez Flores
 * @version May 23th 2013
 */
public class Buck extends Ordinario
{
    /**
     * Gives the properties to an instance of this class.
     */
    public Buck()
    {
        super();
        super.storeImages(5, "buck");
    }
    
    /**
     * Makes Buck act in the World
     */
    public void act() 
    {
        if (!this.getRemoveFlag())
        {
            super.thomasDetection(60);
            super.attackTiming(120);
            super.act();
        }
        else
            super.removeEnemy();
    }
    
    /**
     * This defines how Buck it is going to attack an instance of Thomas class.
     */
    public void attack()
    {
        World world=getWorld();
        Cuchillo knife=null;
        switch(Greenfoot.getRandomNumber(30))
        {
            case 2:
                if (!super.getAttackedFlag())
                {
                    knife = new Cuchillo(super.getDirection());
                    world.addObject(knife, this.getX(), this.getY());
                    this.setImage(super.getElement(2));
                    super.setAttackedFlag(true);
                }
                break;
            case 5: this.setImage(super.getElement(4)); break;
            case 7:
                if (!super.getAttackedFlag())
                {
                    knife = new Cuchillo(super.getDirection());
                    world.addObject(knife, this.getX(), this.getY());
                    this.setImage(super.getElement(3));
                    super.setAttackedFlag(true);
                }
                break;
        }
    }
}
